using System;
using System.Data;
using System.Text;
using System.Data.OleDb; 
using System.Data.SqlTypes; 
using System.Runtime.InteropServices;
using System.Globalization;
using System.Resources; 
using System.Threading;
using System.Reflection; 
using System.Collections; 
using System.Runtime.CompilerServices;
using System.EnterpriseServices;
using System.Net;
using Engine;

namespace Gencode
{
	
	public class Year
	{
        public static Library.myService.Service service = new Library.myService.Service();
        public Year()
		{
            service = new Library.myService.Service();
            SetAuthen();
        }

        public static void SetAuthen() 
        {
            Library.myService.AuthHeader authen = new Library.myService.AuthHeader();
            authen.Username = "violympicservice";
            authen.Password = "violympic12345%$#@!";
            service.AuthHeaderValue = authen;
            Config config = Setting.ReadConfig();
            service.Url = config.dataService;
            if(!config.active)
                return;
            
            NetworkCredential cr = new System.Net.NetworkCredential(config.user,config.pass,config.domain);
            System.Net.WebProxy wb = new System.Net.WebProxy(config.serverProxy,true);
            wb.Credentials = cr;
            service.Proxy = wb;
        }

		public YearInfo Load()
		{
            //SetAuthen();
            YearInfo objInfo = new YearInfo();
            objInfo.ID = service.LoadYear();
            System.Console.WriteLine("Danh sach cac nam la: " + objInfo.ID.ToString());
		    return objInfo;
		}
		
	private String GetResString(String resKey)
	{
		ResourceManager res = new ResourceManager("Gencode",
		Assembly.GetExecutingAssembly());
		String strReturnVal = res.GetString(resKey);
		return strReturnVal;
	}
   }
}